dc_loc <- geocode("Washington, D.C.")
## Source : https://maps.googleapis.com/maps/api/geocode/json?address=Washington,+D.C.&key=xxx-EvQ
dc_map <- qmap(c(lon=dc_loc$lon, lat=dc_loc$lat), source="google", zoom=12)
## Source : https://maps.googleapis.com/maps/api/staticmap?center=38.907192,-77.036871&zoom=12&size=640x640&scale=2&maptype=terrain&language=en-EN&key=xxx-EvQ
dc_map

ph_loc <- geocode("Philadelphia")
## Source : https://maps.googleapis.com/maps/api/geocode/json?address=Philadelphia&key=xxx-EvQ
ph_map <- qmap(c(lon=ph_loc$lon, lat=ph_loc$lat), source="google", zoom=12)
## Source : https://maps.googleapis.com/maps/api/staticmap?center=39.952584,-75.165222&zoom=12&size=640x640&scale=2&maptype=terrain&language=en-EN&key=xxx-EvQ
ph_map

ny_loc <- geocode("New York")
## Source : https://maps.googleapis.com/maps/api/geocode/json?address=New+York&key=xxx-EvQ
ny_map <- qmap(c(lon=ny_loc$lon, lat=ny_loc$lat), source="google", zoom=12)
## Source : https://maps.googleapis.com/maps/api/staticmap?center=40.712775,-74.005973&zoom=12&size=640x640&scale=2&maptype=terrain&language=en-EN&key=xxx-EvQ
ny_map

# lv_loc <- geocode("Clark County, N.V.")
# lv_map <- qmap(c(lon=lv_loc$lon, lat=lv_loc$lat), source="google", zoom=12)
# lv_map
world <- ne_countries(scale = "medium", returnclass = "sf")
class(world)
## [1] "sf" "data.frame"
ggplot(data = world) +
geom_sf(color = "black", fill = "lightgreen") +
xlab("Longitude") + ylab("Latitude") +
ggtitle("World map", subtitle = paste0("(", length(unique(world$NAME)), " countries)"))

ggplot(data = world) +
geom_sf(aes(fill = pop_est)) +
scale_fill_viridis_c(option = "plasma", trans = "sqrt")

world_points<- st_centroid(world)
world_points <- cbind(world, st_coordinates(st_centroid(world$geometry)))
sites <- data.frame(longitude = c(-80.144005, -80.109), latitude = c(26.479005, 26.83))
sites <- st_as_sf(sites, coords = c("longitude", "latitude"), crs = 4326, agr = "constant")
ggplot(data = world) +
geom_sf(fill= "antiquewhite") +
geom_sf(data = sites, size = 4, shape = 23, fill = "darkred") +
geom_text(data= world_points,aes(x=X, y=Y, label=name),
color = "darkblue", fontface = "bold", check_overlap = FALSE) +
annotate(geom = "text", x = -90, y = 26, label = "Gulf of Mexico",
fontface = "italic", color = "grey22", size = 6) +
annotation_scale(location = "bl", width_hint = 0.5) +
annotation_north_arrow(location = "bl", which_north = "true",
pad_x = unit(0.75, "in"), pad_y = unit(0.5, "in"),
style = north_arrow_fancy_orienteering) +
coord_sf(xlim = c(-102.15, -74.12), ylim = c(7.65, 33.97), expand = FALSE) +
xlab("Longitude") +
ylab("Latitude") +
ggtitle("Map of the Gulf of Mexico and the Caribbean Sea") +
theme(panel.grid.major = element_line(color = gray(.5), linetype = "dashed", size = 0.5),
panel.background = element_rect(fill = "aliceblue"))
## Scale on map varies by more than 10%, scale bar may be inaccurate
